﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">Different interpretations of MVVM</title>
  <keywords>
    <keyword translate="true">Introduction</keyword>
    <keyword translate="true">MVVM</keyword>
  </keywords>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Different interpretations of MVVM</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">There are two different interpretations of MVVM, the &quot;purist&quot; way where the model is protected, or the &quot;shortcut&quot; way where the view model only provides the instance of the model and the view then binds directly to the model.</text></para>
    <para styleclass="Normal"><image src="mvvm_interpretations.png" scale="80.00%" width="533" height="314" styleclass="Image Caption"></image></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Shortcut interpretation</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">This is what most people do. The view model once implements the model, and then provides the model to the view. The view then </text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-weight:bold;" translate="true">Advantages</text></para>
    <list id="3" type="ul" listtype="bullet" formatstring="&#183;" format-charset="SYMBOL_CHARSET" levelreset="true" legalstyle="false" startfrom="1" styleclass="Normal (list)" style="font-family:Symbol; font-size:10pt; color:#000000;">
      <li styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Easy to use</text></li>
      <li styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Fast since view model hardly contains any properties</text></li>
    </list>
    <para styleclass="Normal"><text styleclass="Normal" style="font-weight:bold;" translate="true">Disadvantages</text></para>
    <list id="4" type="ul" listtype="bullet" formatstring="&#183;" format-charset="SYMBOL_CHARSET" levelreset="true" legalstyle="false" startfrom="1" styleclass="Normal (list)" style="font-family:Symbol; font-size:10pt; color:#000000;">
      <li styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Always need to bind to </text><text styleclass="Normal (list)" style="font-style:italic;" translate="true">Model.[PropertyName]</text><text styleclass="Normal (list)" translate="true">, but for view model properties it&apos;s just </text><text styleclass="Normal (list)" style="font-style:italic;" translate="true">[PropertyName]</text><text styleclass="Normal (list)" translate="true">, might be confusing</text></li>
      <li styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Less control over validation (you cannot insert logic between View &lt;=&gt; Model where MVVM is all about</text></li>
    </list>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Purist interpretation</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">This is what the developers of Catel strongly believe in. It requires a bit more code, but gives great freedom and control and protection of the model because all bindings go through the view model.</text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-weight:bold;" translate="true">Advantages</text></para>
    <list id="5" type="ul" listtype="bullet" formatstring="&#183;" format-charset="SYMBOL_CHARSET" levelreset="true" legalstyle="false" startfrom="1" styleclass="Normal (list)" style="font-family:Symbol; font-size:10pt; color:#000000;">
      <li styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Full contol and freedom, you can inject both logic and validation between view and model (what MVVM is actually about)</text></li>
      <li styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Everything is available on the view model, no need for &quot;sub-bindings&quot; (such as </text><text styleclass="Normal (list)" style="font-style:italic;" translate="true">Model.[PropertyName]</text><text styleclass="Normal (list)" style="font-style:normal;" translate="true">)</text></li>
      <li styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Protection of your model from the view</text></li>
    </list>
    <para styleclass="Normal"><text styleclass="Normal" style="font-weight:bold;" translate="true">Disadvantages</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Needs a bit more code (but thanks to code snippets and the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_ExposeAttribute" styleclass="Normal" style="font-style:normal;" translate="true">Expose attribute</link><text styleclass="Normal" style="font-style:normal;" translate="true">, this is not a big disadvantage)</text></para>
  </body>
</topic>
